const INFO_KEY = 'hjh_info'
const SEARCH_HISTORY = 'search_history'

// 获取个人信息
export const getInfo = () => {
  return localStorage.getItem(INFO_KEY) ? JSON.parse(localStorage.getItem(INFO_KEY)) : {
    token: '',
    userId: ''
  }
}

// 设置个人信息
export const setInfo = (info) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(info))
}

// 移除个人信息
export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY)
}

// 设置搜索历史
export const setHistory = (searchList) => localStorage.setItem(SEARCH_HISTORY, JSON.stringify(searchList || []))

// 设置搜索历史
export const getHistory = () => JSON.parse(localStorage.getItem(SEARCH_HISTORY) || '[]')
